This example will get you the next Monday. Date.commercial(Date.today.year, 1+Date.today.cweek, 1) If you need the next or previous Monday, whichever is closest, you can do: Date.commercial(Date.today.year, Date.today.cwday.modulo(4)+Date.today.cweek, 1) I can't execute this right now, so forgive me if there are syntax errors.
Share, comment, bookmark or report
select (case datename(dw, aws.date) when 'Monday' then 1 when 'Tuesday' then 2 when 'Wednesday' then 3 when 'Thursday' then 4 when 'Friday' then 5 when 'Saturday' then 6 when 'Sunday' then 7 end) At least, this won't change if someone changes the parameter on the day of the week when weeks begin.
Share, comment, bookmark or report
I have done like var date = DateTime.Today.AddDays(-1); which is giving me yesterday's date. but if I run my application on Monday then I should get Friday date please suggest me expression for this. for example. if today is Monday and date is 21/12/2001 it should give me 19/12/2001 i.e Fridays date if today is Tuesday and date is 21/12/2001 it should return me 20/12/2001 as normal
Share, comment, bookmark or report
How would I write a statement that says: If today is Monday, then run this function. My thoughts are: if datetime.now().day == Monday: run_report() But I know this is not the right way to ...
Share, comment, bookmark or report
date +%u gives you the day of the week from Monday (1) through to Sunday (7). If it's greater than 5 (Saturday is 6 and Sunday is 7), then it's the weekend. So you could put something like this at the top of your script:
Share, comment, bookmark or report
I have a field with dd-mm-yy hh:mm:ss tt I want to select only the name of the day I tried datepart() and day() both gave me 1 to 31. What I want is Monday, Tuesday and so on.. How to achieve ...
Share, comment, bookmark or report
The trick is this tiny VBScript script that outputs the day of the week as a number (1 = Sunday, 2 = Monday, ... 7 = Saturday): WScript.Echo DatePart("w", Date) You can run this script from your batch file, read its output and apply your logic:
Share, comment, bookmark or report
Dim today As Date = Date.Today Dim dayIndex As Integer = today.DayOfWeek If dayIndex < DayOfWeek.Monday Then dayIndex += 7 'Monday is first day of week, no day of week should have a smaller index End If Dim dayDiff As Integer = dayIndex - DayOfWeek.Monday Dim monday As Date = today.AddDays(-dayDiff)
Share, comment, bookmark or report
Looking for a SQL query/queries that would determine the start day (Monday) of the current week. Example: If today is -> then the start of the week is Sat Oct 09, 2010 -> Start of the week is
Share, comment, bookmark or report
(Date.today + 1.week).beginning_of_week(:monday) where you can provide the day you'd like to find as a symbol argument; the default is :monday. Note that this will find the next occurrence of the given day - if today is Monday and you're looking for the next Monday, it will return the Monday one week from today. Some equivalent ways to do it:
Share, comment, bookmark or report
Comments